<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/admin/css/pintuer.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/admin/css/admin.css">
    <script src="${pageContext.request.contextPath}/admin/js/jquery.js"></script>
    <script src="${pageContext.request.contextPath}/admin/js/pintuer.js"></script>  
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head"><strong><span class="icon-key"></span> 修改账号密码</strong></div>
  <div class="body-content">
    <form class="form-x" >
      <div class="form-group">
        <div class="label">
           <label for="sitename">用户名：</label>
        </div>
        <div class="field">
          <label style="line-height:33px;">
           <span id="userName" style="font-weight:bold"></span>
          </label>
        </div>
      </div> 
      <div class="form-group">
        <div class="label">
          <label for="sitename">旧密码：</label>
        </div>
        <div class="field">
          <input id="oldPassword" type="password" class="input w50" id="mpass" name="mpass" size="50" placeholder="请输入原始密码" data-validate="required:请输入原始密码" />       
        </div>
      </div>      
      <div class="form-group">
        <div class="label">
          <label for="sitename">新密码：</label>
        </div>
        <div class="field">
          <input type="password" class="input w50" name="newpass" size="50" placeholder="请输入新密码" data-validate="required:请输入新密码,length#>=5:新密码不能小于5位" />         
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label for="sitename">确认新密码：</label>
        </div>
        <div class="field">
          <input id="newPassword" type="password" class="input w50" name="renewpass" size="50" placeholder="请再次输入新密码" data-validate="required:请再次输入新密码,repeat#newpass:两次输入的密码不一致" />          
        </div>
      </div>
      
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o" type="button" onclick="doChangeWord();"> 确认修改</button>   
        </div>
      </div>      
    </form>
  </div>
</div>
</body>
<script type="text/javascript">

//执行操作加载服务
$(function (){
	//执行ajax操作
	$.ajax({
	 	type:'post',
	 	url:'${pageContext.request.contextPath}/userInfo/loadData2ChangePassword',
	 	data:{},
	 	dataType:'json',
	 	cache:false,
	 	success:function(data)
	 	{	
	 		if(data.success)
	 		{
	 			$("#userName").html(data.entity.accountName);
	 			console.info(data.entity.accountName);
	 		}
	 		else
	 		{
	 			alert(data.message);
	 		}
	 	},
	 	error:function(data)
	 	{
	 		alert('系统出现异常!');
	 	}
	});
});

//加载执行登录操作
function doChangeWord(){
	
	//获取新密码和旧密码	
	var oldPassword = $("#oldPassword").val();
	var newPassword = $("#newPassword").val();
	console.log("旧密码："+oldPassword+" -- 新密码："+newPassword);
	//执行ajax操作
	$.ajax({
	 	type:'post',
	 	url:'${pageContext.request.contextPath}/userInfo/doChangePassword',
	 	data:{"oldPassword":oldPassword,"newPassword":newPassword},
	 	dataType:'json',
	 	cache:false,
	 	success:function(data)
	 	{	
	 		if(data.success)
	 		{
	 			alert(data.message);
	 		}
	 		else
	 		{
	 			alert(data.message);
	 		}
	 	},
	 	error:function(data)
	 	{
	 		alert('系统出现异常!');
	 	}
	});
}
</script>
</html>